<template>
  <div class="setting-card">
    <el-form :model="form" ref="ruleFormRef" :rules="rules">
      <el-form-item label="系统语言" prop="lang">
        <el-select v-model="form.lang">
          <el-option label="中文" value="zh"></el-option>
          <el-option label="English" value="en"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="系统时区" prop="date">
        <el-select v-model="form.date">
          <el-option label="中国" value="zh"></el-option>
          <el-option label="English" value="en"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="系统主题" prop="style">
        <el-select v-model="form.style">
          <el-option label="暗黑" value="an"></el-option>
          <el-option label="亮白" value="white"></el-option>
        </el-select>
      </el-form-item>
    </el-form>
  </div>
  <div class="setting-foot">
    <el-button type="primary" @click="submitForm(ruleFormRef)"
      >确认更新</el-button
    >
  </div>
</template>
<script setup>
import { ref } from "vue";
const ruleFormRef = ref();
const form = ref({
  lang: "zh",
  date: "zh",
  style: "an",
});
const rules = ref({
  lang: [{ required: true, message: "请选择系统语言", trigger: "change" }],
  date: [{ required: true, message: "请选择系统时区", trigger: "change" }],
  style: [{ required: true, message: "请选择系统主题", trigger: "change" }],
});
const submitForm = async (formEl) => {
  if (!formEl) return;
  await formEl.validate((valid, fields) => {
    if (valid) {
      console.log("submit!");
    } else {
      console.log("error submit!", fields);
    }
  });
};
</script>
<style lang="scss" scoped>
.setting-card {
  border: 1px solid #e4e4e4;
  padding: 24px;
  .el-input,
  .el-select {
    width: 290px;
  }
}
.setting-foot {
  margin-top: 24px;
  text-align: right;
}
</style>